<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get the decimal digit value of a code point for a given radix</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="intlchar.chr.html">« IntlChar::chr</a></li>
      <li style="float: right;"><a href="intlchar.enumcharnames.html">IntlChar::enumCharNames »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.intlchar.html">IntlChar</a></li>
    <li>Get the decimal digit value of a code point for a given radix</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="intlchar.digit" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">IntlChar::digit</h1>
  <p class="verinfo">(PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">IntlChar::digit</span> &mdash; <span class="dc-title">Get the decimal digit value of a code point for a given radix</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-intlchar.digit-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>IntlChar::digit</strong></span>(<span class="methodparam"><span class="type"><span class="type">int</span>|<span class="type">string</span></span> <code class="parameter">$codepoint</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$base</code><span class="initializer"> = 10</span></span>): <span class="type"><span class="type">int</span>|<span class="type"><span class="type false">false</span></span>|<span class="type">null</span></span></div>

  <p class="para rdfs-comment">
   Returns the decimal digit value of the code point in the specified radix.
  </p>
  <p class="para">
   If the radix is not in the range <code class="literal">2&lt;=radix&lt;=36</code> or if the value of <code class="parameter">codepoint</code>
   is not a valid digit in the specified radix, <strong><code>false</code></strong> is returned.
   A character is a valid digit if at least one of the following is true:
   <ul class="simplelist">
    <li class="member">The character has a decimal digit value. Such characters have the general category &quot;Nd&quot; (decimal digit numbers) and a Numeric_Type of Decimal. In this case the value is the character&#039;s decimal digit value.</li>
    <li class="member">The character is one of the uppercase Latin letters &#039;A&#039; through &#039;Z&#039;. In this case the value is c-&#039;A&#039;+10.</li>
    <li class="member">The character is one of the lowercase Latin letters &#039;a&#039; through &#039;z&#039;. In this case the value is ch-&#039;a&#039;+10.</li>
    <li class="member">Latin letters from both the ASCII range (0061..007A, 0041..005A) as well as from the Fullwidth ASCII range (FF41..FF5A, FF21..FF3A) are recognized.</li>
   </ul>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-intlchar.digit-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">codepoint</code></dt>

    <dd>

     <p class="para">The <span class="type">int</span> codepoint value (e.g. <code class="literal">0x2603</code> for <em class="emphasis">U+2603 SNOWMAN</em>), or the character encoded as a UTF-8 <span class="type">string</span> (e.g. <code class="literal">&quot;\u{2603}&quot;</code>)</p>
    </dd>

   
   
    <dt>
<code class="parameter">base</code></dt>

    <dd>

     <p class="para">
      The radix (defaults to <code class="literal">10</code>).
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-intlchar.digit-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the numeric value represented by the character in the specified radix,
   or <strong><code>false</code></strong> if there is no value or if the value exceeds the radix. Returns <strong><code>null</code></strong> on failure.
  </p>
  <div class="warning"><strong class="warning">警告</strong><p class="simpara">此函数可能返回布尔值
<strong><code>false</code></strong>，但也可能返回等同于 <strong><code>false</code></strong> 的非布尔值。请阅读 <a href="language.types.boolean.html" class="link">布尔类型</a>章节以获取更多信息。应使用
<a href="language.operators.comparison.html" class="link">===
运算符</a>来测试此函数的返回值。</p></div>
 </div>


 <div class="refsect1 examples" id="refsect1-intlchar.digit-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2497">
   <p><strong>示例 #1 Testing different code points</strong></p>
   <div class="example-contents">
    <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlChar</span><span style="color: #007700">::</span><span style="color: #0000BB">digit</span><span style="color: #007700">(</span><span style="color: #DD0000">"0"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlChar</span><span style="color: #007700">::</span><span style="color: #0000BB">digit</span><span style="color: #007700">(</span><span style="color: #DD0000">"3"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlChar</span><span style="color: #007700">::</span><span style="color: #0000BB">digit</span><span style="color: #007700">(</span><span style="color: #DD0000">"A"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">IntlChar</span><span style="color: #007700">::</span><span style="color: #0000BB">digit</span><span style="color: #007700">(</span><span style="color: #DD0000">"A"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">16</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程会输出：</p></div>
   <div class="example-contents screen">
    <div class="cdata"><pre>
int(0)
int(3)
bool(false)
int(10)
</pre></div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-intlchar.digit-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="intlchar.fordigit.html" class="function" rel="rdfs-seeAlso">IntlChar::forDigit()</a> - Get character representation for a given digit and radix</span></li>
    <li class="member"><span class="function"><a href="intlchar.chardigitvalue.html" class="function" rel="rdfs-seeAlso">IntlChar::charDigitValue()</a> - Get the decimal digit value of a decimal digit character</span></li>
    <li class="member"><span class="function"><a href="intlchar.isdigit.html" class="function" rel="rdfs-seeAlso">IntlChar::isdigit()</a> - Check if code point is a digit character</span></li>
    <li class="member"><strong><code>IntlChar::PROPERTY_NUMERIC_TYPE</code></strong></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>